'''
Function:
    定义地图
author:
    walker
time:
    2020/5/14
'''

class Grid():
    def __init__(self):
        self.info = '根据grid（也就是橡子）的位置更改地图'

    def grid_to_string(self,grid,player):

        #获取到水所处的位置
        water_buckets_pos = []
        # for i in range(len(grid)):
        #     for j in range(len(grid[0])):
        #         if grid[i][j] == 'W':
        #             water_buckets_pos.append([i,j])
        #         if grid[i][j] == 'A':
        #             #原来的player所处位置
        #             grid[i][j] = ' '

        # grid[player.][]
        print("@@@@@@@@@@@@@@@@")
        print([player.row_pre,player.col_pre])
        print([player.row,player.col])
        print(grid[player.row_pre][player.col_pre])
        print(grid[player.row_pre])
        print("@@@@@@@@@@@@@@@@")
        if grid[player.row_pre][player.col_pre] == 'W':
            player.num_water_buckets += 1
            grid[player.row_pre][player.col_pre] = ' '
        # #判断如果player在当前和某一个
        # if [player.row,player.col] in water_buckets_pos:
        #     player.num_water_buckets += 1
        # 先预定义一个空的字符串用于存储grid
        grid_str_list = ''

        grid[player.row][player.col] = player.display
        # print("1111111111111111111")
        for grid_item in grid:
            # print(grid_item)
            grid_str_list += ''.join(grid_item)
            grid_str_list += '\n'
        return grid_str_list,player.num_water_buckets
